image src and relative path

image src and relative path

am 20.12.2007 13:57:28 von Bob Bedford

Hello,

I'm trying to show images that are in a protected directory. I can't move
those images and I can't set the path rights
The path of my script:
home/www/xxxxxxxxxx/web/showimages.php
The path of the images:
home/www/xxxxxxxxxx/stats/image.png

home/www/xxxxxxxxxx/web/ is the root of the website.

Now I've tried so far:
//this asks the user and pass for the
protected directory
//this shows
http://www.mysite.com/home/www....in image properties
//this one also asks for user and pass of the
protected directory.

Si my question is: how to show this image on this page ?

Thanks a lot for helping.

Bob

Re: image src and relative path

am 20.12.2007 15:23:23 von Lars Eighner

In our last episode, <476a66ce$0$29602$5402220f@news.sunrise.ch>, the lovely
and talented Bob Bedford broadcast on comp.lang.php:

> Hello,

> I'm trying to show images that are in a protected directory.

Not possible. Put the images in a world-readable directory or have users
enter username and password. Why in the world would you think otherwise?

You seem to want two contradictory and mutually exclusive things: you want
the images protected (otherwise, why did you put them in a protected
directory?) and you want them publicly accessible (otherwise why do you
object to authentication?) You cannot have both.

> I can't move those images and I can't set the path rights

Then copy them to an unprotected directory.

> The path of my script:
> home/www/xxxxxxxxxx/web/showimages.php
> The path of the images:
> home/www/xxxxxxxxxx/stats/image.png

> home/www/xxxxxxxxxx/web/ is the root of the website.

> Now I've tried so far:
> //this asks the user and pass for the
> protected directory
> //this shows
> http://www.mysite.com/home/www....in image properties
> //this one also asks for user and pass of the
> protected directory.

> Si my question is: how to show this image on this page ?

> Thanks a lot for helping.

> Bob


--
Lars Eighner usenet@larseighner.com
Countdown: 397 days to go.

Re: image src and relative path

am 20.12.2007 22:34:56 von Bob Bedford

Hello Lars, thanks for answering.
> Not possible. Put the images in a world-readable directory or have users
> enter username and password. Why in the world would you think otherwise?
>
> You seem to want two contradictory and mutually exclusive things: you want
> the images protected (otherwise, why did you put them in a protected
> directory?) and you want them publicly accessible (otherwise why do you
> object to authentication?) You cannot have both.
>
>> I can't move those images and I can't set the path rights
>
> Then copy them to an unprotected directory.

It's in a protected directory becuse they are statistics for the website and
the Hosting company decided so and it can't be changed.
I'm the webmaster and I can give access to the client to certain directory
(where they are my scripts) so the concurrents can't see what's appening as
this is a secret.

Also I've tried to do a "imagepng()" but instead of showing the image it
shows the source of the image.
The possibility to show images exists (you can show a document with imagejpg
or others) so why not if coming from a protected directory ?

Bob

Re: image src and relative path

am 21.12.2007 01:17:00 von Lars Eighner

In our last episode, <476ae01e$0$29602$5402220f@news.sunrise.ch>, the lovely
and talented Bob Bedford broadcast on comp.lang.php:

> Hello Lars, thanks for answering.
>> Not possible. Put the images in a world-readable directory or have users
>> enter username and password. Why in the world would you think otherwise?
>>
>> You seem to want two contradictory and mutually exclusive things: you want
>> the images protected (otherwise, why did you put them in a protected
>> directory?) and you want them publicly accessible (otherwise why do you
>> object to authentication?) You cannot have both.
>>
>>> I can't move those images and I can't set the path rights
>>
>> Then copy them to an unprotected directory.

> It's in a protected directory becuse they are statistics for the website and
> the Hosting company decided so and it can't be changed.
> I'm the webmaster and I can give access to the client to certain directory
> (where they are my scripts) so the concurrents can't see what's appening as
> this is a secret.

> Also I've tried to do a "imagepng()" but instead of showing the image it
> shows the source of the image.
> The possibility to show images exists (you can show a document with imagejpg
> or others) so why not if coming from a protected directory ?

Because that is what being in a protected directory means. Any server or
software that would work around permissions would pose a serious security
risk. You may be right that these particular data do not need that kind of
protection. In that case your argument is with the policy of the hosting
company. But software that refuses to violate permissions is doing the
right thing, and any that did not would be hopelessly broken.

--
Lars Eighner usenet@larseighner.com
Countdown: 396 days to go.

Re: image src and relative path

am 21.12.2007 01:43:15 von Michael Fesser

..oO(Lars Eighner)

>In our last episode, <476a66ce$0$29602$5402220f@news.sunrise.ch>, the lovely
>and talented Bob Bedford broadcast on comp.lang.php:
>
>> I'm trying to show images that are in a protected directory.
>
>Not possible. Put the images in a world-readable directory or have users
>enter username and password. Why in the world would you think otherwise?

You can still deliver them with a script, which has full access to the
server's disk (with respect to the filesystem permissions), not only to
the document root. Of course there should be an authorization mechanism
of any kind implemented (in the script itself or by .htaccess).

Sometimes you can also use symbolic links to map those outside files
into the document root, but this depends on the server configuration.

Micha

Re: image src and relative path

am 21.12.2007 01:45:23 von Michael Fesser

..oO(Bob Bedford)

>Also I've tried to do a "imagepng()" but instead of showing the image it
>shows the source of the image.

This means that you've sent an inappropriate HTTP Content-Type header or
none at all, so the server will default to text/plain. Quite easy to fix
with a header() call.

Micha

Re: image src and relative path

am 21.12.2007 09:25:33 von Bob Bedford

>>Also I've tried to do a "imagepng()" but instead of showing the image it
>>shows the source of the image.
>
> This means that you've sent an inappropriate HTTP Content-Type header or
> none at all, so the server will default to text/plain. Quite easy to fix
> with a header() call.
>
Hi Micha,
thanks for replying.

The problem is that I've to show html code and images on the same document.
I tried this:
header('Content-type: text/plain');
header('Content-type: image/png',false);

but the image is still shown as text.
How can I set multiple headers ?

Re: image src and relative path

am 21.12.2007 13:21:42 von Toby A Inkster

Bob Bedford wrote:

> The problem is that I've to show html code and images on the same
> document.

Yes, this is the problem. The solution should be self-evident.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 13 days, 22:57.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/11/28/itunes-sharing/

Re: image src and relative path

am 21.12.2007 14:03:04 von Michael Fesser

..oO(Bob Bedford)

>The problem is that I've to show html code and images on the same document.
>I tried this:
>header('Content-type: text/plain');
> header('Content-type: image/png',false);

Of course this cannot be done. One URL, one document.
You need a second script to fetch the image.

Micha

Re: image src and relative path

am 21.12.2007 17:46:41 von Betikci Boris

On Dec 20, 2:57=A0pm, "Bob Bedford" wrote:
> Hello,
>
> I'm trying to show images that are in a protected directory. I can't move
> those images and I can't set the path rights
> The path of my script:
> home/www/xxxxxxxxxx/web/showimages.php
> The path of the images:
> home/www/xxxxxxxxxx/stats/image.png
>
> home/www/xxxxxxxxxx/web/ is the root of the website.
>
> Now I've tried so far:
> //this asks the user and pass for the
> protected directory
> //this showshttp://www.m=
ysite.com/home/www....inimage properties
> //this one also asks for user and pass of t=
he
> protected directory.
>
> Si my question is: how to show this image on this page ?
>
> Thanks a lot for helping.
>
> Bob




The usage is something like that;

$url =3D 'http://username:password@hostname/path?arg=3Dvalue#anchor';

Re: image src and relative path

am 21.12.2007 17:51:12 von Michael Fesser

..oO(Betikci Boris)

>The usage is something like that;
>
>$url = 'http://username:password@hostname/path?arg=value#anchor';

This is not a valid HTTP URL.

You can use something like this inside your script to fetch data from a
remote location, because PHP will automatically turn the credentials
into proper HTTP authentication headers, but for anything else this is
not allowed.

Micha

Re: image src and relative path

am 22.12.2007 01:03:27 von Bucky Kaufman

"Michael Fesser" wrote in message
news:faenm390hol9gjafv6e2g07mfq1vvrvnqd@4ax.com...
> .oO(Bob Bedford)
>
>>The problem is that I've to show html code and images on the same
>>document.
>>I tried this:
>>header('Content-type: text/plain');
>> header('Content-type: image/png',false);
>
> Of course this cannot be done. One URL, one document.
> You need a second script to fetch the image.

There are ways around this, but they can be damned tough.

The simplest is to base-64 encode the binary image, and put that data
inline.
That way, instead of linking to the binary data, it's right there in the
HTML code.
That has the added benefit of giving you an oportunity to manipulate the
image (stretch, watermark, etc) for each session.

Re: image src and relative path

am 22.12.2007 01:03:27 von Bucky Kaufman

"Betikci Boris" wrote in message
news:1b3de3d4-2953-4c1d-b0fe-9ab9078a5433@r60g2000hsc.google groups.com...

> The usage is something like that;
> $url = 'http://username:password@hostname/path?arg=value#anchor';

That'll work - but bear in mind that there's no LESS secure way of sending
passwords than via the URL.
Not only does it go over the net unencoded, but it also remains in a variety
of "history" records.

Re: image src and relative path

am 22.12.2007 18:43:08 von Michael Fesser

..oO(Sanders Kaufman)

>"Michael Fesser" wrote in message
>news:faenm390hol9gjafv6e2g07mfq1vvrvnqd@4ax.com...
>>
>> Of course this cannot be done. One URL, one document.
>> You need a second script to fetch the image.
>
>There are ways around this, but they can be damned tough.
>
>The simplest is to base-64 encode the binary image, and put that data
>inline.
>That way, instead of linking to the binary data, it's right there in the
>HTML code.

IE doesn't support data URLs.

Micha

Re: image src and relative path

am 22.12.2007 18:44:40 von Michael Fesser

..oO(Sanders Kaufman)

>"Betikci Boris" wrote in message
>news:1b3de3d4-2953-4c1d-b0fe-9ab9078a5433@r60g2000hsc.googl egroups.com...
>
>> The usage is something like that;
>> $url = 'http://username:password@hostname/path?arg=value#anchor';
>
>That'll work - but bear in mind that there's no LESS secure way of sending
>passwords than via the URL.
>Not only does it go over the net unencoded, but it also remains in a variety
>of "history" records.

That's why it's not allowed at all in HTTP URLs (there might be other
reasons as well).

Micha

Re: image src and relative path

am 23.12.2007 02:17:40 von Bucky Kaufman

"Michael Fesser" wrote in message
news:s3jqm35ai5soij5ghr20tbhd1leq6mn21s@4ax.com...
> .oO(Sanders Kaufman)
>
>>"Michael Fesser" wrote in message
>>news:faenm390hol9gjafv6e2g07mfq1vvrvnqd@4ax.com...
>>>
>>> Of course this cannot be done. One URL, one document.
>>> You need a second script to fetch the image.
>>
>>There are ways around this, but they can be damned tough.
>>
>>The simplest is to base-64 encode the binary image, and put that data
>>inline.
>>That way, instead of linking to the binary data, it's right there in the
>>HTML code.
>
> IE doesn't support data URLs.

Yeah - IE messes a LOT of stuff up.
CSS hovers don't work right either.
That's why we almost *always* have to code branches for if they use IE.

Re: image src and relative path

am 27.12.2007 16:33:30 von Bob Bedford

>> The problem is that I've to show html code and images on the same
>> document.
>
> Yes, this is the problem. The solution should be self-evident.

The solution may be evident for you but not to everybody (if any). Could you
please explain ?

Re: image src and relative path

am 03.01.2008 10:44:40 von Toby A Inkster

Bob Bedford wrote:

>>> The problem is that I've to show html code and images on the same
>>> document.
>>
>> Yes, this is the problem. The solution should be self-evident.
>
> The solution may be evident for you but not to everybody (if any).

"The problem is that I've to show html code and images on the same
document" so the solution is clearly "stop trying to show HTML code and
images on the same document" -- or, in more practical terms, use two
different PHP files -- one to generate the HTML and one to generate the
image.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 3 days, 20:56.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/11/28/itunes-sharing/

Re: image src and relative path

am 03.01.2008 10:45:35 von Toby A Inkster

Michael Fesser wrote:

> IE doesn't support data URLs.

IE 8 internal betas apparently pass the Acid2 test. Acid2 includes data:.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 3 days, 20:58.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/11/28/itunes-sharing/

Re: image src and relative path

am 06.01.2008 08:30:33 von Tim Roberts

Toby A Inkster wrote:

>Michael Fesser wrote:
>
>> IE doesn't support data URLs.
>
>IE 8 internal betas apparently pass the Acid2 test. Acid2 includes data:.

The odd thing is that they are going to include a switch: you can either
set it in Acid2 mode, or you can set it in IE7-with-all-the-warts mode.

I can guess which option will be the default, and it won't be the one that
breaks compatibility with existing IE-specific web sites.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Re: image src and relative path

am 06.01.2008 14:21:44 von Toby A Inkster

Tim Roberts wrote:

> The odd thing is that they are going to include a switch: you can either
> set it in Acid2 mode, or you can set it in IE7-with-all-the-warts mode.
>
> I can guess which option will be the default, and it won't be the one
> that breaks compatibility with existing IE-specific web sites.

Yes, but this is not a configuration setting, but a switch much like
quirks mode / strict mode that's already been in Windows IE since version
6.0 (and Mac IE since 5.0). The user won't be responsible for turning on
standards mode -- the author will be able to do so using some sort of HTML
syntactical nuance.

(From the language they've been using to describe it, it seems likely that
it's not another DOCTYPE-based switch but will more likely rely on a meta
tag or HTTP header.)

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 7 days, 31 min.]

dhyana.pl/0.3
http://tobyinkster.co.uk/blog/2008/01/06/dhyana/